package fr.univavignon.m1informatique.rgla.pki.is;

import fr.univavignon.m1informatique.rgla.directory.DirectoryException;
import fr.univavignon.m1informatique.rgla.directory.DistinguishedName;
import fr.univavignon.m1informatique.rgla.isarchi.ISArchiException;
import fr.univavignon.m1informatique.rgla.isarchi.ISComponent;
import fr.univavignon.m1informatique.rgla.isarchi.ISComponentType;
import fr.univavignon.m1informatique.rgla.isarchi.OrganizationalUnit;
import fr.univavignon.m1informatique.rgla.pki.IValidationAuthority;
import fr.univavignon.m1informatique.rgla.pki.PKIException;
import fr.univavignon.m1informatique.rgla.pki.types.Certificate;

public class ValidationAuthority extends ISComponent implements
		IValidationAuthority {

	private ISComponentType type;

	public ValidationAuthority(DistinguishedName unitName,
			ISComponentType type, String simpleName) throws DirectoryException,
			ISArchiException {
		super(unitName, type, simpleName);

		this.type = type;
		AnnuaireAuthority.addVA(unitName.getName(), this);
	}

	@Override
	public boolean isCertificateValid(Certificate certificate)
			throws PKIException {
		// TODO Auto-generated method stub
		return AnnuaireAuthority.getCA(this.getUnitName().getName())
				.isCertificateValid(certificate);
	}

	public ISComponentType getType() {
		return type;
	}

	public void setType(ISComponentType type) {
		this.type = type;
	}

}
